/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package stis.statpro.ibs;

import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.jfree.chart.ChartFactory;
import org.jfree.chart.ChartFrame;
import org.jfree.chart.JFreeChart;
import org.jfree.data.category.DefaultCategoryDataset;
import stis.statpro.ibs.dao.PerusahaanDao;
import stis.statpro.ibs.model.Perusahaan;

/**
 *
 * @author habib <imamhabibpamungkas@gmail.com>
 */
public class Chart {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        try {
            DefaultCategoryDataset data = new DefaultCategoryDataset();
            List<Perusahaan> listPer = new ArrayList<Perusahaan>();
            PerusahaanDao pdao = new PerusahaanDao();
            listPer = pdao.getAllData();
            for (Perusahaan p : listPer) {
                data.setValue(p.getAsetDalamRupiah(), "Aset", p.getNamaPrsh());
                data.setValue(p.getOmzetsebulanDalamRupiah(), "Omset Sebulan",Integer.toString(p.getKip()));
            }
            JFreeChart chart = ChartFactory.createBarChart("Mencoba", "Tahun", "Tenaga Kerja", data);
            ChartFrame frame = new ChartFrame("Grafik", chart);
            frame.setSize(450, 300);
            frame.setVisible(true);
        } catch (SQLException ex) {
            Logger.getLogger(Chart.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

}
